package com.volunteer.util;


/**
 * 返回格式
 *
 * @author willow
 * @version v.0.1
 * @date 2018年7月31日
 */
public class ResponseResult {

    // 操作成功
    public static Result genSuccessResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(Constants.DEFAULT_SUCCESS_MESSAGE);
    }

    public static Result genSuccessResult(String message) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(message);
    }

    public static Result genSuccessResult(Object data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(Constants.DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static Result genSuccessResult(String message, Object data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(message)
                .setData(data);
    }

    // 操作失败
    public static Result genFailResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message);
    }

    public static Result genFailResult(ResultCode resultCode, String message) {
        return new Result()
                .setCode(resultCode)
                .setMessage(message);
    }

    // 未登录
    public static Result genNotLogin() {
        return new Result()
                .setCode(ResultCode.UNAUTHORIZED)
                .setMessage(Constants.DEFAULT_FAIL_LOGIN_MESSAGE);
    }

    // 权限不足
    public static Result genPermissions() {
        return new Result()
                .setCode(ResultCode.PERMISSIONS)
                .setMessage(Constants.DEFAULT_FAIL_PERMISSIONS_MESSAGE);
    }

    // 删除失败
    public static Result genFailDeleteResult() {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(Constants.DEFAULT_FAIL_DELETE_MESSAGE);
    }

    // 更新失败
    public static Result genFailUpdateResult() {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(Constants.DEFAULT_FAIL_UPDATE_MESSAGE);
    }

    // 删除成功
    public static Result genSuccessDeleteResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(Constants.DEFAULT_SUCCESS_DELETE_MESSAGE);
    }

    // 更新成功
    public static Result genSuccessUpdateResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(Constants.DEFAULT_SUCCESS_UPDATE_MESSAGE);
    }
}
